/**
 *
 */
package com.monkeyboy.controller;

import com.monkeyboy.service.RocketMQProducer;
import com.monkeyboy.service.rocketmqordermsg.OrderMessageProducer;
import com.monkeyboy.service.rockettransaction.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.monkeyboy.common.dto.ResData;

/**
 *
 *
 * @author Gavin<br>
 *         2020年4月24日
 */
@RestController
public class TestController {
    @Autowired
    private RocketMQProducer producer;
    @Autowired
    private OrderService os;
    @Autowired
    private OrderMessageProducer orderMessageProducer;

    //常规使用
    @GetMapping("/sendMsg")
    public Object test() throws Exception {
        producer.producer();
        return ResData.SUCCESS();
    }

    //发送事务消息
    @GetMapping("/sendTransactionMsg")
    public ResData sendMsg() throws Exception {
        os.createOrder();
        return ResData.SUCCESS("下单成功。");
    }

    //发送顺序消息
    @GetMapping("/sendOrderMessage")
    public ResData sendOrderMsg() throws Exception {
        orderMessageProducer.orderProductMessage();
        return ResData.SUCCESS("发送顺序消息。");
    }
}
